package com.yanqu.road.server.manger.kowloon.battle.buff;

import com.yanqu.road.entity.kowloon.common.KowloonBuffParam;
import com.yanqu.road.entity.kowloon.enums.battle.eKowloonBulletType;
import com.yanqu.road.server.manger.kowloon.battle.KowloonGame;
import com.yanqu.road.server.manger.kowloon.battle.role.bullet.KowloonBullet;
import com.yanqu.road.server.manger.kowloon.battle.role.enemy.KowloonEnemy;
import com.yanqu.road.server.manger.kowloon.battle.role.hero.KowloonHero;

import java.util.List;

public abstract class KowloonBuff {

    /**
     * 游戏相关数据
     */
    public KowloonGame game;

    public KowloonBuffParam baseData;

    public eKowloonBulletType type;

    public KowloonHero caster;

    public KowloonEnemy owner;

    public double startTime;

    public double endTime;

    public double effectTime;
    public KowloonBullet bullet;

    public abstract List<KowloonBuffEffect> getBuffEffect();

    public KowloonBuff(KowloonGame game, KowloonBullet bullet, KowloonEnemy owner) {
        this.bullet = bullet;
        this.type = bullet.getBulletType();
        this.baseData = bullet.getBuffParam();
        this.caster = bullet.getShooter();
        this.owner = owner;
        this.game = game;
        this.startTime = game.gameTime;
        this.endTime = this.startTime + this.baseData.getDuration();
        this.initData();
    }

    public void initData() {

    }

    public void update(double dt) {
        if (game.gameTime >= this.endTime) {
            this.owner.removeBuff(this);
        } else {
            this.processEffect();
        }
    }

    public static KowloonBuff createBuff(KowloonGame game, KowloonBullet bullet, KowloonEnemy owner) {
        KowloonBuff buff = null;
        switch (bullet.getBulletType()) {
            case Fish:
                buff = new KowloonBuff1(game, bullet, owner);
                break;
            case Inkfish:
                buff = new KowloonBuff2(game, bullet, owner);
                break;
            case Spear:
                buff = new KowloonBuff3(game, bullet, owner);
                break;
            case Amulet:
                buff = new KowloonBuff4(game, bullet, owner);
                break;
            case Football:
                buff = new KowloonBuff5(game, bullet, owner);
                break;
            default:
                break;
        }
        return buff;
    }

    /**
     * 处理buff效果
     */
    public void processEffect() {

    }

    public void clear() {

    }

}
